{% extends "mall/base.html" %}

{% block title %}
    确认订单
{% endblock %}

{% block css %}
    <link rel="stylesheet" href="{{ STATIC_URL }}/static/css/mall/cart.css?v={{ version_code }}">
    <script type="text/javascript">
        window.onload = function () {
            if(window.name != "pay_confirm"){
                location.reload();
                window.name = 'pay_confirm';
            }else{
                window.name = "";
            }
        }
    </script>
{% endblock %}

{% block header %}
{% endblock %}

{% block content %}
    <input type="hidden" name="device_id" value="{{ device_id }}">
    <input type="hidden" name="address_id" value="{{ address.sdef_address_id }}">

    <div class="page" id="J-page">
        <div id="J-receiving-info">
            <div class="receiving-info">
                <div class="list" data-is-login="" data-allow-diff-warehouse="" id="J-list">
                    <a href="javascript:" class="list-item media more J-address-login set-address">
                        <div class="item-content">
                            <div class="item-inner">
                                <div class="item-title-row">
                                    <div class="item-title">
                                        设置收货地址
                                    </div>
                                </div>
                            </div>
                            <i class="icon-back"></i>
                        </div>
                    </a>
                </div>
            </div>
        </div>

        <div id="J-identify-card">
        </div>

        <div id="J-cart-info">
            <div class="shopping-cart-info-box" id="J-shopping-cart-info-box">
                <div class="section section-cart-order ui-list">
                    {% if address.sdef_address_phone %}
                        <div class="ui-list-header-item {% if cart_goods_array|length > 0 %}ui-border-b{% endif %}">
                            <h2 class="single-line">
                                收货地址： {{ address.sdef_address_province }} {{ address.sdef_address_city }} {{ address.sdef_address_county }}
                                {{ address.sdef_address_detail }}
                                【{{ address.sdef_address_name }} {{ address.sdef_address_phone }}】
                            </h2>
                        </div>
                    {% endif %}

                    <ul>
                        {% for foo in cart_goods_array %}
                            <li class="ui-list-item" data-balance_rate="{{ foo.balance_rate }}">
                                <input type="hidden" name="price" value="{{ foo.goods_price }}">
                                <div class="ui-list-item-inner">
                                    <a href="#"
                                       class="ui-list-item-thumb">
                                        <img src="{{ foo.goods_img }}">
                                        <!--  -->
                                    </a>

                                    <div class="ui-list-item-info">
                                        <a href="#" class="meta">
                                            <h4 class="title"> {{ foo.goods_name }}
                                            </h4>
                                        </a>

                                        <div class="stock clearfix" style="padding:0 2px;">
                                            <a href="javascript:;"
                                               class="ui-button ui-button-border ui-button-border-gray ui-button-border-small cart-count-control"
                                               data-value="-1">
                                                <i class="iconfont icon-minus"></i>
                                            </a>

                                            <span>{{ foo.count }}</span>
                                            <input class="amount-num J-amount-num" data-id="{{ foo.id }}" type="text"
                                                   readonly="readonly"
                                                   value="{{ foo.count }}" name="num">

                                            <a href="javascript:;"
                                               class="ui-button ui-button-border ui-button-border-gray ui-button-border-small J-cart-info-plus cart-count-control"
                                               data-value="1">
                                                <i class="iconfont icon-plus"></i>
                                            </a>

                                            {% if order_type != 4 and order_type != "4" %}
                                                <a href="javascript:;" class="close J-cart-info-delete">
                                                    <i class="iconfont icon-close"></i>
                                                </a>
                                            {% endif %}
                                        </div>
                                        <a href="#" class="price">
                                            <span class="original-price">￥{{ foo.goods_price }}</span>

                                        </a>
                                    </div>
                                </div>
                            </li>
                        {% endfor %}


                    </ul>
                </div>
            </div>
        </div>

        {% if cart_goods_array|length > 0 %}
            <div id="J-checkout-money">
                <div class="J-checkout-money-wrap">
                    <ul class="u-checkout-money">
                        <li class="title ui-border-b">订单金额
                          <span>
                                {% if order_type == 4 or order_type == "4" %}
                                    <b class="total-price" style="text-decoration:line-through;color:#808080;">¥ 199.00</b>&nbsp;&nbsp;¥&nbsp;<b>{{ price_total }}</b>
                                {% else %}
                                    ¥&nbsp;<b class="total-price">{{ price_total }}</b>
                                {% endif %}
                           </span>
                        </li>
                        <li class="item-money">微信支付 <span>¥&nbsp;<b
                                id="wechatFee">{{ wechat_fee | round(2) }}</b></span>
                        </li>
                        <li class="item-money" style="height: 30px;">余额抵扣 <span>¥&nbsp;
                        <input type="text" id="txtBalanceFee" value="{{ balance_fee | round(2) }}"
                               style="width: 50px;border:1px solid #eee;text-align: right;color:#585c64">
                        </span>
                        </li>
                        <li class="item-money" style="height: 50px;">
                            {#                            留言#}
                            <span>
                                <textarea placeholder="请输入留言内容" id="txaMessage"
                                          style="width: 98%;height:45px;line-height:18px;border:1px solid #eee;text-align: left;color:#585c64"></textarea>

                            </span>
                        </li>
                    </ul>
                </div>

            </div>
        {% endif %}
        {% if cart_goods_array|length > 0 %}
            {% if address.sdef_address_phone %}
                <div class="u-checkout-pay checkout-pay">
                    <!-- 发货提示 -->
                    <div class="J-cart-tips" id="J-cart-tips">
                        <div class="J-cart-tips-main" id="J-cart-tips-main">
                            <span>配送到：{{ address.sdef_address_detail }}</span><span>  【工作日17:00前下单，当天发货。】</span>
                        </div>
                    </div>
                    <div class="pay-content J-pay-content border-t">
                        <div class="total-money">账户余额:<span>¥&nbsp;<b id="balanceMoney">
                            {% if account_money %}
                                {{ enable_account_money }}
                            {% else %}
                                0.00
                            {% endif %}
                        </b></span>
                        </div>
                        <!-- 接收银台 -->
                        <div class="btn-group clearfix">
                            <p class="disabled-delivery-msg"></p>

                            {% if account_money and account_money.ebf_am_is_forbid == 0 and enable_account_money > 0 %}
                                <input type="hidden" name="account_money" value="{{ account_money.ebf_am_money }}">
                            {% else %}
                                <input type="hidden" name="account_money" value="0">
                            {% endif %}

                            <button type="button" class="btn btn-right btn-pay-online pay" id="pay" style="width: 100%"
                                    data-method="2">立即支付
                            </button>

                        </div>
                    </div>
                </div>
            {% else %}
                <div class="u-checkout-pay checkout-pay">
                    <div class="pay-content J-pay-content border-t">
                        <div class="total-money">您还未设置收货地址，请先 <a href="javascript:" class="set-address"
                                                                 style="color: blue">设置收货地址</a></div>
                    </div>
                </div>
            {% endif %}
            <div class="gift" id="gift" style="visibility: hidden">
                <i class="fa fa-gift" aria-hidden="true"></i>
            </div>
        {% else %}
            <div class="u-checkout-pay checkout-pay">
                <div class="pay-content J-pay-content border-t">
                    <div class="total-money">还没选购商品～ <a href="/mall">赶快去<b style="color:blue">商城</b>选购商品吧</a></div>
                </div>
            </div>
        {% endif %}
    </div>
{% endblock %}

{% block footer %}
    <!--END Toast-->
    <div id="webform" style="display: none"></div>
{% endblock %}

{% block js %}
    <script>
        // 页面唯一的随机数
        var uniqueStr = "{{ unique_str }}";
        var orderType = "{{ order_type }}";
    </script>
    <script src="{{ STATIC_URL }}/static/js/mall/pay-confirm.js?v={{ version_code }}"></script>
{% endblock %}

